/*
 * VotedBinaryClassifier.cpp
 *
 *  Created on: Apr 11, 2010
 *      Author: Soheil Damangir
 */

#include "VotedBinaryClassifier.h"
#include <string>
#include <iostream>
#include "log.h"
using kthrobot::Log;

namespace Group5 {

VotedBinaryClassifier::VotedBinaryClassifier(std::istream&is){
  is >> dim;
  while(is.good())
  {
    addClassifier(is);
  }
}

bool VotedBinaryClassifier::addClassifier(const BinaryBayesian&classifier)
{
  if (classifier.get_dim() != dim)
  {
    return false;
  }
  else
  {
    classifiers.push_back(classifier);
    return true;
  }
}
bool VotedBinaryClassifier::addClassifier(std::istream&is)
{
  return addClassifier(BinaryBayesian(is));
}
bool VotedBinaryClassifier::classify(const int*P)
{
  int32_t total_conf = 0;
  for(it = classifiers.begin(); it!=classifiers.end(); ++it)
  {
    total_conf += it->classify(P);
  }
  return total_conf > 0;
}


VotedBinaryClassifier::~VotedBinaryClassifier() {
}

}
